﻿<UserControl x:Class="SLAdmin.UserControls.EditSurvey"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:extended="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
    xmlns:liquid="clr-namespace:Liquid;assembly=Liquid"
    xmlns:images="clr-namespace:SLAdmin.Images"    
    xmlns:extensions="clr-namespace:SLExtensions.Controls;assembly=SLExtensions.Controls"    
    xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
    xmlns:converters="clr-namespace:Common.Converters;assembly=Common"
             LayoutUpdated="UserControl_LayoutUpdated"
             >
    <UserControl.Resources>
        <converters:ImageUriConverter x:Name="myImageUriConverter"/>
        <converters:PathFileNameConverter x:Name="myPathFileNameConverter"/>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Style="{StaticResource MainDockBackground2}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="100"/>
                <RowDefinition Height="1*"/>
                <RowDefinition Height="50"/>
            </Grid.RowDefinitions>
            <Grid Grid.Row="0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="130" />
                    <ColumnDefinition Width="1*"/>
                </Grid.ColumnDefinitions>
                <Image Grid.Column="0" Margin="10" Source="icons/survey_128.png" />
                <TextBox Grid.Column="1" Text="{Binding SurveyName, Mode=TwoWay}" Style="{StaticResource TextBoxMainHeadline}"/>
            </Grid>
            <Border Grid.Row="2" Style="{StaticResource BorderBottomPanel}">
                <Button x:Name="btnSave" 
                        Style="{StaticResource Button_Save}"                    
                        Click="btnSave_Click">
                    <StackPanel Orientation="Horizontal">
                        <Image Source="icons/filesave-32.png"/>
                        <TextBlock Margin="5,0,0,0"
                               VerticalAlignment="Center" 
                               Text="Save"/> 
                            </StackPanel>
                </Button>
            </Border>
            <extended:TabControl x:Name="StudyTabs" Background="White" 
                                 Grid.Row="1"
                                 SelectionChanged="StudyTabs_SelectionChanged">
                <extended:TabItem Padding="5">
                    <extended:TabItem.Header>
                        <StackPanel Margin="5" Orientation="Horizontal">
                            <Image Source="icons/configure_32.png"/>
                            <TextBlock Text="General" 
                                   Style="{StaticResource TextBlockTabName}"
                                   />
                    </StackPanel>
                    </extended:TabItem.Header>
                    <extensions:DockPanel Style="{StaticResource DockMainTabPage}">
                        <Border extensions:DockPanel.Dock="Bottom" Style="{StaticResource BorderTabBottomPanel}">
                            <Button x:Name="btnCreatePage" Click="btnCreatePage_Click"  Style="{StaticResource ButtonMedium}">
                                <StackPanel Orientation="Horizontal">
                                    <Image Source="icons/Page.png"/>
                                    <TextBlock Text="New Page" 
                                           Margin="5,0,0,0" 
                                           VerticalAlignment="Center" />    
                            </StackPanel>
                            </Button>
                        </Border>
                        <ScrollViewer Style="{StaticResource ScrollViewerTabWindow}">
                            <StackPanel Orientation="Vertical">
                                <data:DataGrid x:Name="SurveyPageGrid"
                                               AutoGenerateColumns="False"
                                                
                                                HeadersVisibility="Column"
                                                RowBackground="White"
                                                AlternatingRowBackground="LightGray"
                                                CanUserResizeColumns="False"                                                
                                                RowHeight="45">
                                    <data:DataGrid.Columns>
                                        <data:DataGridTemplateColumn Width="34">
                                            <data:DataGridTemplateColumn.CellTemplate>
                                                <DataTemplate>
                                                    <Image Source="icons/Page.png" Margin="3" />
                                                </DataTemplate>
                                            </data:DataGridTemplateColumn.CellTemplate>
                                        </data:DataGridTemplateColumn>
                                        <data:DataGridTextColumn MinWidth="200" Width="Auto" 
                                                                 Binding="{Binding PageName, Mode=TwoWay}"/>
                                        <data:DataGridTemplateColumn Width="Auto" MinWidth="150">
                                            <data:DataGridTemplateColumn.CellTemplate>
                                                <DataTemplate>
                                                    <StackPanel Orientation="Horizontal">
                                                        <Button Margin="5" x:Name="Up" Click="Up_Click">
                                                            <images:UpIcon ></images:UpIcon>
                                                        </Button>
                                                        <Button Margin="5" x:Name="Down" Click="Down_Click">
                                                            <images:DownIcon></images:DownIcon>
                                                        </Button>
                                                        <Button Margin="5" x:Name="Delete" Click="Delete_Click">
                                                            <images:DeleteIcon/>
                                                        </Button>
                                                    </StackPanel>
                                                </DataTemplate>
                                            </data:DataGridTemplateColumn.CellTemplate>
                                        </data:DataGridTemplateColumn>
                                    </data:DataGrid.Columns>
                                </data:DataGrid>
                            </StackPanel>
                        </ScrollViewer>
                    </extensions:DockPanel>
                </extended:TabItem>
                <extended:TabItem x:Name="tabResources" >
                    <extended:TabItem.Header>
                        <StackPanel Margin="5" Orientation="Horizontal">
                            <Image Source="icons/pictures_32.png"/>
                            <TextBlock Text="Resources" Style="{StaticResource TextBlockTabName}"/>
                    </StackPanel>
                    </extended:TabItem.Header>
                    <extensions:DockPanel Style="{StaticResource DockMainTabPage}">
                        <Border extensions:DockPanel.Dock="Bottom" Style="{StaticResource BorderTabBottomPanel}">
                            <StackPanel Orientation="Horizontal">
                                <Button x:Name="btnUploadFile" Click="btnUploadFile_Click" Style="{StaticResource ButtonMedium}">
                                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                                        <Image Source="icons/up-32.png"/>
                                        <TextBlock Text="Upload File" 
                                               Margin="5,0,0,0" 
                                               VerticalAlignment="Center" />    
                                    </StackPanel>
                                </Button>
                            </StackPanel>
                        </Border>
                        <ScrollViewer Style="{StaticResource ScrollViewerTabWindow}">
                            <data:DataGrid x:Name="ResourcesGrid"
                                               AutoGenerateColumns="False"
                                                
                                                HeadersVisibility="Column"
                                                RowBackground="White"
                                                AlternatingRowBackground="LightGray"
                                                CanUserResizeColumns="False"                                                
                                                RowHeight="120">
                                <data:DataGrid.Columns>
                                    <data:DataGridTemplateColumn Width="200">
                                        <data:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <StackPanel Orientation="Vertical">
                                                    <Image Height="100" Source="{Binding '', Converter={StaticResource myImageUriConverter}}"/>
                                                    <TextBlock Margin="0,5,0,0" HorizontalAlignment="Center" Text="{Binding '',Converter={StaticResource myPathFileNameConverter}}"/>
                                                </StackPanel>
                                            </DataTemplate>
                                        </data:DataGridTemplateColumn.CellTemplate>
                                    </data:DataGridTemplateColumn>
                                    <data:DataGridTemplateColumn Width="50" MinWidth="50">
                                        <data:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <Button Margin="3" Click="btnDeleteResource_Click" 
                                                        VerticalAlignment="Center"
                                                        x:Name="btnDeleteResource" Height="45">
                                                    <images:DeleteIcon/>
                                                </Button>
                                            </DataTemplate>
                                        </data:DataGridTemplateColumn.CellTemplate>
                                    </data:DataGridTemplateColumn>
                                </data:DataGrid.Columns>
                            </data:DataGrid>
                        </ScrollViewer>
                    </extensions:DockPanel>
                </extended:TabItem>
            </extended:TabControl>
        </Grid>
    </Grid>
</UserControl>
